package com.hjxr.quota.datasource.domain;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Date;

/**
 * 数据表别名表实体类(quota_dimension)
 * @author sun
 * @version v1.0
 * @since 2020-08-16
 */
@Data
@ApiModel
@TableName("quota_tablename_alias")
@KeySequence(value = "seq_quota_tablename_alias", clazz = Integer.class)
public class  TablenameAlias extends Model<TablenameAlias> {
    /**
     * 数据表别名表id，自增主键
     */
    @TableId(value = "id", type = IdType.INPUT)
    @ApiModelProperty(value = "数据表别名表id，自增主键")
    private Integer id;

    /**
     *数据源id
     */
    @ApiModelProperty(value = "数据源id")
    private Integer datasourceId;

    /**
     *数据库名称
     */
    @ApiModelProperty(value = "数据库名称")
    private String databaseName;

    /**
     *数据表名称
     */
    @ApiModelProperty(value = "数据表名称")
    private String tableName;

    /**
     *数据表别名
     */
    @ApiModelProperty(value = "数据表别名")
    private String tableNameAlias;

    /**
     *数据表说明
     */
    @ApiModelProperty(value = "数据表说明")
    private String tableDesc;

    /**
     * 更新人
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @ApiModelProperty(value = "更新人")
    private String updateBy;

    /**
     * 更新时间
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @JSONField(format = "yyyy/MM/dd")
    @ApiModelProperty(value = "更新时间", hidden = true)
    private Date updateDate;

    /**
     *状态
     */
//    @TableLogic
    @ApiModelProperty(value = "状态：0.删除，1.启用，2.停用")
    private String status;

    public String getName() {
        return (this.tableNameAlias == null || "".equals(this.tableNameAlias)) ? this.tableName : this.tableNameAlias;
    }
}
